package com.example.bluetooth.ui

import android.content.Context
import kotlin.math.roundToInt

class DisplayUtils {
    companion object {
        fun dp2px(context: Context, dp: Int): Int {
            val density = context.resources.displayMetrics.density
            return (dp * density + 0.5f).roundToInt()
        }

        fun px2dp(context: Context, px: Int): Int {
            val density = context.resources.displayMetrics.density
            return (px / density + 0.5f).roundToInt()
        }

        fun getScreenWidth(context: Context): Int {
            return context.resources.displayMetrics.widthPixels
        }
    }
}